package 一致性组合模式;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.stage.Stage;


public class ClientGUI extends Application {
	public Organization Marvel=new Organization("Marvel");
    public static void main(String[] args)
       {
    	   launch(args);
       }
   	public void start(Stage primaryStage) {
        primaryStage.setTitle("安全组合模式");
        Button btn = new Button();
        btn.setText("创建组织");
        Button btn1=new Button();
        btn1.setText("创建成员");
        Button btn2 =new Button();
        btn2.setText("显示");
        Button btn3 =new Button();
        btn3.setText("删除组织或成员");
        TextField txt=new TextField();//输入人员和组织名
        TextField txt1=new TextField();//显示信息
        txt.setMinWidth(580);
     	txt.setMinHeight(20);
     	txt1.setMinWidth(580);
     	txt1.setMinHeight(300); 
     	txt1.setText("组织Marvel包括：");
     	

        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
               String str=txt.getText();
               Component o=new Organization(str);
               Marvel.add(o);
               }
        });
        btn1.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                  String str=txt.getText();
                  Component p=new Person(str);
                  Marvel.add(p);
               }
        });
        btn2.setOnAction(new EventHandler<ActionEvent>() {
        	@Override
        	public void handle(ActionEvent event) {
        		Marvel.text=" ";
        		txt1.setText("组织Marvel包括：");
        		txt1.setText(txt1.getText()+Marvel.showRelationship()+"\n");
        		
        	}
        });
        btn3.setOnAction(new EventHandler<ActionEvent>() {
        	@Override
        	public void handle(ActionEvent event) {
        		String str=txt.getText();
        		Marvel.remove(str);
        		}
        		
        });
        
 
        FlowPane pane = new FlowPane();   
        pane.setPadding(new Insets(11, 12, 13, 14));
        pane.setHgap(25);//水平距离
        pane.setVgap(25);//垂直距离
        pane.getChildren().add(txt);
        pane.getChildren().add(txt1);
        pane.getChildren().add(btn); 
        pane.getChildren().add(btn1);
        pane.getChildren().add(btn2);
        pane.getChildren().add(btn3);
        
       
        primaryStage.setScene(new Scene(pane, 600, 500));
        primaryStage.show();
	}
}
